﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="分厂库存.aspx.cs" Inherits="syc.Jidong.分厂库存" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>分厂库存</title>
<link rel="stylesheet" href="/js/autocomplete/jquery.autocomplete.css" type="text/css" />
<script src="/js/autocomplete/lib/jquery.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/autocomplete/lib/jquery.bgiframe.min.js"></script>
<script type="text/javascript" src="/js/autocomplete/jquery.autocomplete.js"></script>
<script src="clearbox.js" type="text/javascript"></script>
</head>
<body onload="load();">
<script type="text/javascript" language="javascript" src="/common.js"></script>
    <form id="form1" runat="server">
     <div id="Div1" class="wintop">分厂备品备件库存<br />
     </div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:Panel ID="Panel2" runat="server" CssClass="panel">
            <table style="width:30%;margin-left:5px;">
            <tr>
                <td><input type="button" value="入库" onclick="CB_Open_in();" class="button" /></td>
                <td><input type="button" value="出库" onclick="CB_Open_out();" class="button" /></td>
                <td><input type="button" value="查询" id="search" class="button"/></td>
            </tr>
            </table>
        </asp:Panel>
        
        <asp:Panel ID="Panel3" runat="server" CssClass="panel">
            <table style="width:30%;margin-left:5px;">
            <tr>
            <td>品名：</td>
            <td><input type="text" id="name" /></td>                
            </tr>
            </table>
        </asp:Panel>
  <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>  
    <div class="gridframe">
        <div class="gridview">
        
            <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
	            <tr>
		            <td class="grid-title">备品备件库存

                    </td>
		        </tr>
		        <tr>
		            <td class="grid-back">

                                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"                                           
                            
                                    SelectCommand="SELECT [品名], SUM([数量]) AS 数量 
                                    FROM [备品备件收支表] 
                                    WHERE ([生产线] = @生产线)
                                    GROUP BY [备品备件收支表].[品名]">
                                    <SelectParameters>
                                        <asp:QueryStringParameter DefaultValue="1" Name="生产线" 
                                    QueryStringField="fenchang" Type="Int32" />
                                    </SelectParameters>
                                </asp:SqlDataSource>
                                <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                                    AllowSorting="True" AutoGenerateColumns="False" CssClass="grid" 
                                    DataSourceID="SqlDataSource2" GridLines="None" 
                                    ondatabound="GridView1_DataBound" 
                                    onpageindexchanged="GridView1_PageIndexChanged" 
                                    UseAccessibleHeader="False">
                                    <PagerSettings Visible="False" />
                                    <RowStyle CssClass="grid-row-normal" />
                                    <Columns>
                                        <asp:BoundField DataField="品名" HeaderStyle-CssClass="grid-header" 
                                            HeaderText="品名" ItemStyle-CssClass="grid" ItemStyle-Width="160" 
                                            ItemStyle-HorizontalAlign="Center"
                                            SortExpression="品名">
                                        </asp:BoundField>
                                        <asp:BoundField DataField="数量" HeaderStyle-CssClass="grid-header" 
                                            HeaderText="数量" ItemStyle-CssClass="grid" ItemStyle-Width="160" 
                                            ItemStyle-HorizontalAlign="Center"
                                            SortExpression="数量">
                                        </asp:BoundField>
                                    </Columns>
                                </asp:GridView>
                                <table width="100%">
                                    <tr>
                                        <td class="pagebar">
                                            <asp:Button ID="Button_Pager_First" runat="server" CommandName="--" 
                                                CssClass="pageturn-first-b" onclick="Pager_Click" Text="" ToolTip="首页" />
                                            <asp:Button ID="Button_Pager_Prev" runat="server" CommandName="-" 
                                                CssClass="pageturn-prev-b" onclick="Pager_Click" Text="" ToolTip="上一页" />
                                            <input class="page-split" type="button" />第<asp:TextBox ID="TextBox_Pager" 
                                                runat="server" CssClass="pageturn" ontextchanged="Pager_Click"></asp:TextBox>
                                            页<input class="page-split" type="button" /><asp:Label ID="Label_Pages" 
                                                runat="server"></asp:Label>
                                            <input class="page-split" type="button" />
                                            <asp:Button ID="Button_Pager_Next" runat="server" CommandName="+" 
                                                CssClass="pageturn-next-b" onclick="Pager_Click" Text="" ToolTip="下一页" />
                                            <asp:Button ID="Button_Pager_Last" runat="server" CommandName="++" 
                                                CssClass="pageturn-last-b" onclick="Pager_Click" Text="" ToolTip="末页" />
                                        </td>
                                        <td align="right">
                                            <asp:Label ID="Label_Total" runat="server" CssClass="grid_totalrows"></asp:Label>
                                        </td>
                                    </tr>
                                </table>

		            </td>
	            </tr>
            </table>
                    </div>
    </div>
    </ContentTemplate>
    
    <Triggers>
     <asp:AsyncPostBackTrigger ControlID="button" EventName="Click" />
    </Triggers>
   </asp:UpdatePanel>            


<asp:Button ID="button" runat="server" OnClick="button_Click" style="display:none;"/>
   </form>
<script>
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }

    }
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
        }
    }
    var tds = document.getElementsByTagName("td");
    for (i = 0; i < tds.length; i++) {
        if (tds[i].className == "detailheader") {
            tds[i].innerHTML = tds[i].innerHTML.replace("*", "<span class=required>*</span>");
        }
    }
</script>    
<script type="text/javascript">
    function load() {
        //alert("Hello from Load");
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        EndRequestHandler();
    }

    function EndRequestHandler() {
        //初始化的时候隐藏查询界面
        $("#Panel3").hide();
        $("#search").click(function() {
            //alert("fasd");
            $("#Panel3").toggle();
        });
        $("#name").autocomplete("k.aspx", {
            extraParams: { name: function() { return $('#name').val(); },
                           fenchang: function() { return <%= Request.QueryString["fenchang"] %>; }
             },  
            minChars: 0,
            max: 5,
            autoFill: true,
            mustMatch: true,
            matchContains: true,
            scrollHeight: 220,
            formatItem: function(data, i, total) {
                return "现有库存：<I>" + data[0] + "</I>";
            },
            formatMatch: function(data, i, total) {
                return data[0];
            },
            formatResult: function(data) {
                return data[0];
            }
        });
    }

    //打开入库库判定通知书
    function CB_Open_in() {
        CB_Open('href=/JiDong/备品备件入库.aspx?fenchang=1,,width=650,,height=600');
    }
    //打开出库库判定通知书
    function CB_Open_out() {
        CB_Open('href=/JiDong/备品备件出库.aspx?fenchang=1,,width=650,,height=600');
    }
    //关闭时刷新一下页面
    function CB_ExternalFunctionCBClose() {
        //UpdatePanel实现无页面刷新，参考http://www.douban.com/note/70296807/
        __doPostBack("<%= button.ClientID %>", "");
    }        
</script>
</body>
</html>

